//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.orphan.supplier.controller;


import com.orphan.supplier.po.Goods;
import com.orphan.supplier.service.IGoodsService;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/goods"})
public class GoodsController {
    @Resource
    private IGoodsService goodsService;

    public GoodsController() {
    }

//    @GetMapping({"/insertGoods"})
//    public String insert() {
//        ImportParams params = new ImportParams();
//        params.setTitleRows(0);
//        params.setHeadRows(1);
//        List list = null;
//
//        try {
//            list = ExcelImportUtil.importExcel(new FileInputStream("C:/Users/77185/Desktop/test.xlsx"), Goods.class, params);
//        } catch (Exception var5) {
//            var5.printStackTrace();
//        }
//
//        Iterator var3 = list.iterator();
//
//        while(var3.hasNext()) {
//            Goods goods = (Goods)var3.next();
//            System.out.println("goods = " + goods);
//            this.goodsService.add(goods);
//        }
//
//        return "success";
//    }

    @GetMapping({"/add/{name}/{spec}/{type}/{quantity}"})
    public boolean add(@PathVariable String name, @PathVariable String spec, @PathVariable String type, @PathVariable Integer quantity) {
        Goods goods = new Goods();
        goods.setName(name);
        goods.setQuantity(quantity);
        goods.setSpec(spec);
        goods.setType(type);
        return goodsService.add(goods);
    }

    @GetMapping({"/list"})
    public List<Goods> list() {
        return this.goodsService.list();
    }
}
